package com.cyy.cn.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.cyy.cn.pojo.Problem;
import org.springframework.data.jpa.repository.Query;

/**
 * problem数据访问接口
 * @author Administrator
 *
 */
public interface ProblemDao extends JpaRepository<Problem,String>,JpaSpecificationExecutor<Problem>{

    @Query("select p from Problem p where id in (select problemid from Pl where labelid = ?1) order by replytime desc ")
    public Page<Problem> findNewListByLabelId(String labelId, Pageable pageable);



    /**
     * 根据标签id查询等待回答列表
     */
    @Query("select p from Problem  p where id in (select problemid from Pl where labelid = ?1) and reply = 0 order by createtime desc")
    public Page<Problem> findWaitListByLabelid(String labelid,Pageable pageable);
}
